package com.qf.bootmq.mq;

import com.qf.bootmq.config.RabbitMQConfig;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.util.Map;

@Component
public class BootListener {

    @RabbitListener(queues = {RabbitMQConfig.BOOT_QUEUE})
    public void consume(String msg, Channel channel, Message message) throws IOException {
        Map<String, Object> map = message.getMessageProperties().getHeaders();

        System.out.println("接收到消息：" + msg);
        // 手动ack
        channel.basicAck(message.getMessageProperties().getDeliveryTag(),false);
    }
}
